package com.fz.controller.merchant;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fz.aop.login.AnonymousAccess;
import com.fz.beans.PageBeans;
import com.fz.common.ResponseEntity;
import com.fz.dto.merchant.merJob.MerJobAdd;
import com.fz.dto.merchant.merJob.MerJobQuery;
import com.fz.dto.merchant.merJob.MerJobUpd;
import com.fz.service.merchant.MerJobService;
import com.fz.vo.merchant.merJob.MerJobVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiSort;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "岗位管理")
@RequestMapping("/merJob")
@ApiSort(value = 6)
@SuppressWarnings("unchecked")
public class MerJobController {

    @Resource
    private MerJobService merJobService;

    @GetMapping("/findMerJobList")
    @ApiOperation(value = "分页查询岗位列表")
    @ApiOperationSupport(order = 1)
    @AnonymousAccess
    public ResponseEntity<IPage<MerJobVo>> findMerJobList(MerJobQuery merJobQuery, PageBeans pageBeans) throws Exception{
        return merJobService.findMerJobList(merJobQuery, pageBeans.getPageNum(), pageBeans.getPageSize());
    }

    @PostMapping("/addJob")
    @ApiOperation(value = "新增岗位")
    @ApiOperationSupport(order = 2)
    @AnonymousAccess
    public ResponseEntity addMerJob(@RequestBody MerJobAdd merJobAdd) throws Exception{
        return merJobService.addMerJob(merJobAdd);
    }

    @PostMapping("/updateMerJob")
    @ApiOperation(value = "修改岗位")
    @ApiOperationSupport(order = 3)
    @AnonymousAccess
    public ResponseEntity updateMerJob(@RequestBody MerJobUpd merJobUpd) throws Exception{
        return merJobService.updateMerJob(merJobUpd);
    }
}
